package com.chap18;

import lombok.extern.slf4j.Slf4j;
import org.openjdk.jol.info.ClassLayout;

/**
 * <p>
 * <code>LockEscalationDemo</code>
 * </p>
 *
 * @author junbao3
 * TODO
 * @date 2023-05-17 16:29
 * Copyright (C) 2021 IFlyTek. All rights reserved.
 */
@Slf4j
public class LockEscalationDemo6 {
    public static void main(String[] args) throws InterruptedException {


        Thread.sleep(4000);

        Object obj = new Object();
        log.debug(Thread.currentThread().getName()+"开始执行。。。\n"+ClassLayout.parseInstance(obj).toPrintable());//101   匿名偏向
        new Thread(()->{
            synchronized (obj){
                log.debug(Thread.currentThread().getName()+"获取锁执行中。。。\n"+ClassLayout.parseInstance(obj).toPrintable());//101 偏向锁  538212357

            }

        },"thread1").start();


     }
}
